package com.yanboo.generator.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yanboo.common.base.BaseEntity;
import com.yanboo.common.constant.DataFilterConstant;
import com.yanboo.generator.constant.DbType;
import jakarta.persistence.*;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.*;

@Getter
@Setter
@Entity
@DynamicInsert
@DynamicUpdate
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "db_driver")
//@FilterDef(name = DataFilterConstant.FILTER,parameters={@ParamDef( name = DataFilterConstant.PARAM, type = long.class)})
@Filters(@Filter(name = DataFilterConstant.FILTER, condition = DataFilterConstant.CONDITION))
public class DbDriver extends BaseEntity {

    private String name;

    @Enumerated(value = EnumType.STRING)
    private DbType dbType;

    private String driverClass;

    @JsonIgnore
    private String driverPath;

    public void copy(DbDriver source){

        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
